//package fileupdown;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.File;
//import java.io.IOException;
//import java.sql.Connection;
//import java.sql.SQLException;
//import java.sql.Statement;
//
//@WebServlet("/delete")
//public class DeleteServlet extends HttpServlet {
//    public static final String path = "D:\\CodeAll\\code\\FirstWeb\\src\\main\\webapp\\resourse\\";
//    @Override
//    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
////        super.doGet(req, resp);
//        String shan = req.getParameter("shan");
//        String name = req.getParameter("name");
//        try {
//            Connection connection = JdcbConnection.requestConnection();
//            Statement statement = connection.createStatement();
//            String sql = "DELETE FROM file_table WHERE file_id = '"+shan+"'";
//            int i = statement.executeUpdate(sql);
//        } catch (ClassNotFoundException e) {
//            throw new RuntimeException(e);
//        } catch (SQLException e) {
//            throw new RuntimeException(e);
//        }
//        File file = new File(path + name);
//        //无法删除，因为文件被程序占用
//        boolean delete = file.delete();
//        if (delete){
//            System.out.println("删除成功");
//        }else {
//            System.out.println("删除失败");
//        }
//        resp.sendRedirect("/index");
//    }
//}
